﻿using System;
using System.Data;
using System.Web.UI.WebControls;
using BLL;

namespace UI.ModSalary
{
    public partial class SalaryTrendMonth : System.Web.UI.Page
    {
        SalaryTableBiz salaryTableBiz = new SalaryTableBiz();
        string strMonth = string.Empty;
        string strYear = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["StrMonth"] != null)
            {
                strMonth = Request.Params["StrMonth"].ToString();
                strYear = Request.Params["StrYear"].ToString();
            }
            else
                return;
            if (!IsPostBack)
            {               
                BondGrid(strYear, strMonth);
            }
        }
        private void BindChart(int r, DataTable dt, string yValue, string xValue)
        {

            chMain.ChartAreas["ca"].AxisX.Interval = 1;
            //if (r <= 6)
            //{
            //    chMain.Height = r * 50;
            //    chMain.Width = r * 50;
            //    chMain.Series[0].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Pie;
            //}
            //else
            //{
            chMain.Height = 380;
            chMain.Width = r * 70;
            // }
            chMain.IsSoftShadows = true;
           
            chMain.DataSource = dt;
            chMain.Series[0].YValueMembers = yValue;
            chMain.Series[0].XValueMember = xValue;
            chMain.Series[0].IsValueShownAsLabel = true;
            
            chMain.DataBind();
        }


        private void BondGrid(string strYear, string strMonth)
        {
            DataTable dt = salaryTableBiz.SalaryTrendMonth(strYear,strMonth, "1");
            int r = dt.Rows.Count;

            bTitle.Text = strYear + "年" + strMonth + "月工资金额柱状图";
            BindChart(r, dt, "总额", "部门");
        

        }
    }
}